Skip to content

feat(staged): hover parent-branch capsule to preview upstream commits#758

Merged
matt2e merged 5 commits into
mainfrom
hover-on-upstream-changes
May 29, 2026
Merged

feat(staged): hover parent-branch capsule to preview upstream commits#758
matt2e merged 5 commits into
mainfrom
hover-on-upstream-changes

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented May 29, 2026

Summary

Adds a hover popover on the parent-branch capsule that previews the upstream commits powering the +N badge (merge-base(HEAD, origin/{base})..origin/{base}).

  • New list_parent_branch_commits Tauri command that returns the same range as the badge count, capped at 26 rows (MAX_ROWS + 1) on both workspace and worktree paths to bound the IPC payload and defang the origin/<base> fallback if merge-base fails.
  • ParentBranchCommitsHover Svelte component that lazy-loads the range on hover, renders up to 25 rows + a +N more summary, and invalidates on git-state-updated.
  • Stale-version retries: if git-state-updated fires mid-fetch, the in-flight call would previously leave loading set forever; now we loop while open and always clear loading in finally.
  • Polish: no I-beam cursor on the capsule; header reads "Upstream changes in " so it doesn't repeat the capsule label.

Test plan

  • Hover the parent-branch capsule on a branch with +N > 0; verify the popover lists the same upstream commits.
  • Trigger a git-state-updated (e.g. fetch) while the popover is open; verify it refreshes instead of getting stuck on "Loading…".
  • Open on a branch hundreds of commits behind base; verify only 26 rows cross IPC and the popover shows 25 + "more" summary.

matt2e added 5 commits May 29, 2026 14:04
Adds a `list_parent_branch_commits` Tauri command returning the
merge-base(HEAD, origin/{base})..origin/{base} commit range — the same
range powering the `+N` badge — and a `ParentBranchCommitsHover`
component that lazy-loads and renders it as a popover when the parent
capsule is hovered. The cache invalidates on `git-state-updated`.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Stops the parent-branch capsule from showing a text I-beam on hover and
restyles the popover header to "Upstream changes in <baseBranch>" so it
doesn't just repeat the capsule label.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
If `git-state-updated` fired while `listParentBranchCommits` was in
flight, the in-flight call saw a version mismatch and skipped clearing
`loading` in `finally`, so every subsequent `loadCommits()` early-
returned and the popover was stuck on "Loading…" until unmount. Wrap
the fetch in a `while (open)` loop that transparently refetches on
stale versions, and unconditionally clear `loading` in `finally`.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
`ParentBranchCommitsHover` is only mounted when `parentAheadCount > 0`
(see `BranchCardHeaderInfo.svelte`), so the `count <= 0` early-return
inside `scheduleOpen` can never fire. Remove the dead guard to match
the rest of the file's trust-the-caller style.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
`list_parent_branch_commits` had no upper bound on either the workspace
or worktree path, so a branch hundreds of commits behind its base
would ship the full range across the IPC boundary even though the
popover renders 25 rows + a `+N more` summary. Worse, on `merge-base`
failure the bare `origin/<base>` revspec would walk to the root commit
of the base branch. Add `--max-count=26` (MAX_ROWS + 1) on both paths
to bound the payload and defang the fallback.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners May 29, 2026 06:28
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 835b02b151

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

fn parse_parent_commit_lines(lines: &[String]) -> Vec<ParentBranchCommit> {
let mut commits = Vec::new();
for line in lines {
let parts: Vec<&str> = line.splitn(6, '|').collect();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a robust delimiter for parent commit parsing

When an upstream commit subject or author contains | (for example feat: add foo | bar), this parser shifts the remaining fields because git log --format=%H|%h|%s|%an|%ae|%ct does not escape that delimiter; the hover then shows the wrong author/email and usually a 0 timestamp. This affects only commits with that character, but those commit subjects are valid and will make the new preview misleading; use a NUL/record separator or parse a format with unambiguous delimiters.

Useful? React with 👍 / 👎.

@matt2e matt2e merged commit 5819383 into main May 29, 2026
5 checks passed
@matt2e matt2e deleted the hover-on-upstream-changes branch May 29, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant